projects
/
gtk4.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
447203c
)
text: Optimize away 0-change insertions and deletions
author
Matthias Clasen
<mclasen@redhat.com>
Thu, 4 Mar 2021 19:14:09 +0000
(14:14 -0500)
committer
Matthias Clasen
<mclasen@redhat.com>
Thu, 4 Mar 2021 20:18:30 +0000
(15:18 -0500)
We can short-circuit insert and delete calls that are
not causing any change.
gtk/gtktext.c
patch
|
blob
|
history
diff --git
a/gtk/gtktext.c
b/gtk/gtktext.c
index 7791029e52607ccd83b31997aa0ec39b4df22100..20c7fee84158f976bcdb3ec7f43e1a8fb8d451d0 100644
(file)
--- a/
gtk/gtktext.c
+++ b/
gtk/gtktext.c
@@
-3309,6
+3309,9
@@
gtk_text_insert_text (GtkText *self,
int n_inserted;
int n_chars;
+ if (length == 0)
+ return;
+
n_chars = g_utf8_strlen (text, length);
/*
@@
-3338,6
+3341,9
@@
gtk_text_delete_text (GtkText *self,
{
GtkTextPrivate *priv = gtk_text_get_instance_private (self);
+ if (start_pos == end_pos)
+ return;
+
begin_change (self);
gtk_entry_buffer_delete_text (get_buffer (self), start_pos, end_pos - start_pos);